<?
define( "MEMCACHED_ENABLED", false );

class ccdsConfig
{


/* ---------------------------------------------------------------------------------------------------------------------------------- */

    private $name="ccdsConfig";

    private $settings=array();


/* ---------------------------------------------------------------------------------------------------------------------------------- */

    function __construct( )
    {

        $path=dirname( dirname( dirname( __FILE__ ) ) );
        include( $path . "/ccds_config/config.inc.php" );

        $this->settings['mysql']=$CCDS_CONFIG['mysql'];

        $this->settings['DOC_ROOT']=$CCDS_CONFIG['paths']['doc_root'];
        $this->settings['WEB_ROOT']=$CCDS_CONFIG['paths']['web_root'];
        //$this->settings['PHP_CLASS_ROOT'] = $settings['MMCMS_CMS_CLASS_ROOT'];
        //$this->settings['PHP_CLASS_DIR'] = $settings['MMCMS_CMS_CLASS_DIR'];

        $this->settings['CMS_ROOT']=$CCDS_CONFIG['paths']['cms_root'];
        $this->settings['CMS_WEB_DIR']=$this->settings['WEB_ROOT'] . $this->settings['CMS_ROOT'];
        $this->settings['CMS_WEB_ROOT']=$CCDS_CONFIG['paths']['web_root'];

        $this->settings['TPL_DIR']=
            $this->settings['DOC_ROOT'] . $this->settings['WEB_ROOT'] . $this->settings['CMS_ROOT'] . "templates/";

        $this->settings['MEDIA_DIR']=
            $this->settings['DOC_ROOT'] . $this->settings['WEB_ROOT'] . $CCDS_CONFIG['paths']['media_dir'];
        $this->settings['MEDIA_WEB']=$this->settings['WEB_ROOT'] . $CCDS_CONFIG['paths']['media_dir'];
        $this->settings['MEDIA']=$this->settings['MEDIA_DIR'];

        $this->settings['EXTENSION_DIR']=
            $this->settings['DOC_ROOT'] . $this->settings['WEB_ROOT'] . $CCDS_CONFIG['paths']['extension_dir'];
        $this->settings['EXTENSION_WEB']=$this->settings['WEB_ROOT'] . $CCDS_CONFIG['paths']['extension_dir'];
        //$this->settings['EXTENSION_FTP'] = $settings['MMCMS_FTP_WEB_ROOT'].$this->settings['EXTENSION_DIR'];

        $this->settings['LIBRARY_DIR']=
            $this->settings['DOC_ROOT'] . $this->settings['WEB_ROOT'] . $CCDS_CONFIG['paths']['library_dir'];
        $this->settings['LIBRARY_WEB']=$this->settings['WEB_ROOT'] . $CCDS_CONFIG['paths']['library_dir'];

        $this->settings['DIR_CHMOD']=$CCDS_CONFIG['chmod']['dirs'];
        $this->settings['FILE_CHMOD']=$CCDS_CONFIG['chmod']['files'];

        $this->settings['USE_FTP']=$CCDS_CONFIG['ftp']['enable'];

        $this->settings['FTP_WEB_ROOT']=$CCDS_CONFIG['ftp']['web_root'];
        $this->settings['FTP_HOST']=$CCDS_CONFIG['ftp']['host'];
        $this->settings['FTP_PORT']=$CCDS_CONFIG['ftp']['port'];
        $this->settings['FTP_USER']=$CCDS_CONFIG['ftp']['user'];
        $this->settings['FTP_PASS']=$CCDS_CONFIG['ftp']['pass'];

        $this->settings['RESIZE_ENGINE']=$CCDS_CONFIG['images']['engine'];
        $this->settings["IMAGE_CACHE_DIR"]=
            $this->settings['DOC_ROOT'] . $this->settings['WEB_ROOT'] . $CCDS_CONFIG['images']['path'];

        $this->settings['SMARTY_CACHE_ROOT']=$CCDS_CONFIG['smarty']['cache_root'];
        $this->settings['SMARTY_COMPILE_DIR']=$this->settings['SMARTY_CACHE_ROOT'] . $CCDS_CONFIG['smarty']['compile'];
        $this->settings['SMARTY_CACHE_DIR']=$this->settings['SMARTY_CACHE_ROOT'] . $CCDS_CONFIG['smarty']['cache'];
        $this->settings['SMARTY_CONFIG_DIR']=$this->settings['SMARTY_CACHE_ROOT'] . $CCDS_CONFIG['smarty']['config'];

        $this->settings['SMARTY_DIR']=$this->settings['LIBRARY_DIR'] . "smarty/";

        $this->settings['ADMIN_MAIL']=$CCDS_CONFIG['global']['admin_email'];

        $this->settings['VARCACHE']=$CCDS_CONFIG['varcache'];

        $this->settings['MODULE_DIR']=
            $this->settings['DOC_ROOT'] . $this->settings['WEB_ROOT'] . $this->settings['CMS_ROOT'] . "modules/";

        $this->settings['DEFAULT_LANG']=$CCDS_CONFIG['global']['default_lang'];
    }

/* ---------------------------------------------------------------------------------------------------------------------------------- */
    public function get( $key )
    {
        if ( isset( $this->settings[$key] ) )
            return $this->settings[$key];

        return;
    }
/* ---------------------------------------------------------------------------------------------------------------------------------- */
    public function set( $key, $value )
    {

        $this->settings[$key]=$value;

        return;
    }
/* ---------------------------------------------------------------------------------------------------------------------------------- */

    static function &getInstance( )
    {
        static $obj;

        if ( !$obj )
        {
            $obj=new ccdsConfig();
        }
        return $obj;
    }
}
